<include file="Common/works/search_header" />
<script>
function show(obj,id) {    
    var objDiv = $("#"+id+"");
    $(objDiv).css("display","block");
}
function hide(obj,id) {
    var objDiv = $("#"+id+"");
    $(objDiv).css("display", "none");
}
</script>
<div class="main" id="main">
	<div class="address" style=" background-image:none"></div>
	<div class="details" id="tab1">
		<div class="top">
			<div class="left">
				<img src="{$data[0].service_logo}" title="{$data[0].services_name}" />
			</div>
			<div class="right">
				<div class="title">{$data[0].services_name}</div>
				<div class="details">{$data[0].service_introduction}</div>
        
        <if condition="$data[0]['tag_string'] neq ''">
        <?php $tag_list_recommend = explode(',',$data[0]['tag_string']); ?>
        <!-- 2016-9-2 添加 -->
        <div class="information label">
          <foreach name="tag_list_recommend" item="tag_rec" key="tag_rec_key">
            <if condition="$tag_rec_key lt 3">
            <div><span>&middot;</span>{$tag_rec}</div>
            </if>
          </foreach>
        </div>
        <!-- 2016-9-2 添加end -->
        </if>

				<div class="information">服务商：{$data[0].service_publisher}</div>
				<div class="information">更新时间：{$data[0].service_update_time}</div>
				<div class="ul" id="api_list_id">
					<foreach name="data" item="value" key="key">
					<div class="li">
						<a id="api_list_{$value.api_id}" onclick="getServiceAPi({$value.service_id},{$value.api_id})" <if condition="$key eq 0">class="hr"</if> >{$value.api_name}</a>
					</div>
          </foreach>
					<div class="cls"></div>
				</div>
				<div class="authorizationt"><span>*</span>提示：您现在查看的是<span>预览页面</span></div>
			</div>
		</div>
		
		<input type="hidden" value='{$data[0].service_request_heads}' id="req_head"/>
		<input type="hidden" value='{$data[0].service_response_heads}' id="resp_head"/>
		<div class="cls"></div>


		<div id="service_api_info_content"></div>

		<script id="service_api_id" type="text/html">
<div class="middle"> <a id="parent_con_one_1" onclick="setTab('con_one_1')" title="api" class="hr">API</a><a id="parent_con_one_2" onclick="setTab('con_one_2')" title="错误代码参照" style="border-right-height:5px;">错误代码参照</a> </div>
    <div class="tail" id="tail">
      <div class="right" id="con_one_1">
        <div class="wz"><strong>API名称:</strong>{{api_name}}</div>
        <div class="wz"><strong>API介绍:</strong>{{api_introduction}}</div>
        <div class="wz"><strong>数据更新类型:</strong> 
          <!-- 二选一 --> 
          {{if api_update_type == 1}}
            <a class="real_time">实时更新</a> 
           {{else if api_update_type == 2 }}
            <a class="static_data">静态数据</a> 
          {{/if}}
        </div>
        <div class="wz"><strong>收费类型:</strong> 
          <!-- 二选一 --> 
          {{if api_is_charge == 0}}
            免费
           {{else if api_is_charge == 1 }}
            收费 
          {{/if}}
        </div>
        <div class="wz"><strong>接口地址:</strong>https://api.37degree.com/open/{{service_name_en}}/{{api_name_en}}</div>
		<div class="lbk">
			<div class="wzz">请求示例:</div>
		       <div class="lb">
					<textarea class="textarea1" autocomplete="on" readonly="readonly"/>curl   '{{api_sample_url}}'	 -H 'Authorization:Basic base64_encryption(email:token)'</textarea>
                <div class="fieldd">使用HTTP Basic Authentication方式做访问授权,HTTP Header里加一个字段(Key/Value对) Authorization: Basic base64_auth_string，其中 base64_auth_string 的生成算法为: base64(eamil:token) 即用email加上冒号, 加上token拼接起来, 再做base64编码转换。</div>
				</div>
			<div class="cls"></div>
		</div>
        
        {{if api_request_method == 0}}
            <div class="wz"><strong>请求方式:</strong>GET/POST</div>
        {{else if api_request_method == 1}}
        	  <div class="wz"><strong>请求方式:</strong>POST</div>
         {{ else if api_request_method == 2}}	
            <div class="wz"><strong>请求方式:</strong>GET</div>
         {{/if}}    
        
        <div class="wz"><strong>返回格式:</strong>{{api_result_format}}</div>
        <div class="wzz">授权方式:</div>
        <div class="wz wzkd"><span>{{api_authorized_type}}</span></div>

        {{if service_request_heads}}
				<div class="lbk">
					<div class="wz none">
						<strong class="service">http请求头</strong>(Request Headers)：
					</div>

					<div class="table-responsive wzkd">
						<table class="table table-bordered table-striped">
							<colgroup>
								<col class="col-xs-3">
								<col class="col-xs-3">
							</colgroup>
							<thead>
								<tr>
									<th class="text-left">参数</th>
									<th class="text-left">值</th>
								</tr>
							</thead>

							<tbody>
								<!-- 循环go -->
                {{each service_request_heads as value key}}
								<tr>
									<td>{{value.name}}</td>
									<td>{{value.value}}</td>
								</tr>
								 {{/each}}
								<!-- 循环end -->
							</tbody>
						</table>
					</div>
					<div class="cls"></div>
				</div>
        {{/if}}

        {{if service_response_heads}}
					<div class="lbk">
         			 <div class="wz none"><strong class="service">http响应头</strong>(Response Headers)：</div>
		  
                        <div class="table-responsive wzkd">
            			<table class="table table-bordered table-striped">
              			<colgroup>
              			<col class="col-xs-3">
              			<col class="col-xs-3">
            			  </colgroup>
             		    <thead>
               			 <tr>
          				    <th class="text-left">参数</th>
              			    <th class="text-left">值</th>
            			 </tr>
          			    </thead>
              
          			    <tbody>
          			  <!-- 循环go -->
                        {{each service_response_heads as value key}}
						  <tr>
                  		  <td>{{value.name}}</td>
                 		  <td>{{value.value}}</td>
               			  </tr>
              		    {{/each}}
           			 <!-- 循环end --> 
           			 </tbody>
           			 </table>
                     </div>
                  <div class="cls"></div>
                </div>
        {{/if}}

        {{if api_request_param.length >0 }}
        <div class="lbk" id="lbkone">
          <div class="wzz">请求参数:</div>
          <div class="lb">

            <div class="table-responsive">
            <table class="table table-bordered table-striped">
              <colgroup>
              <col class="col-xs-2">
              <col class="col-xs-1">
              <col class="col-xs-1">
              <col class="col-xs-2">
              <col class="col-xs-4">
              </colgroup>
              <thead>
                <tr>
                  <th class="text-left">参数名</th>
                  <th class="text-left">类型</th>
                  <th class="text-left">是否必填</th>
                  <th class="text-left">示例默认值</th>
                  <th class="text-left">说明</th>
                </tr>
              </thead>
              
              <tbody>
           {{each api_request_param as value key}}
                <tr>
                  <td>{{value.name}}</td>
                  <td>{{value.type}}</td>
                  {{if value.mast == 0}}
                     <td> <code>否</code> </td>
                  {{else}}
					 <td> <code>是</code> </td>
                   {{/if}}
                  <td>{{value.default_value}}</td>
                  <td class="pr"><div class="text-overflow-fix w3" >{{value.desc}}</div>
                      <a data-show-intro="" class="text-overflow-fix"><span>展开</span><i class="ml5 caret caret-b-9b caret-down"></i></a></td>
                </tr>
           
          {{/each}}
             </tbody>
            </table>
          </div>
          </div>
          <div class="cls"></div>
        </div>
        {{/if}}

        {{if api_result_field.lenght > 0 }}
        <div class="lbk">
          <div class="wzz">返回字段:</div>
          <div class="lb">
      
			   <div class="table-responsive">
            <table class="table table-bordered table-striped">
              <colgroup>
              <col class="col-xs-3">
              <col class="col-xs-3">
              <col class="col-xs-4">
              </colgroup>
              <thead>
                <tr>
                  <th class="text-left">字段名</th>
                  <th class="text-left">类型</th>
                  <th class="text-left">说明</th>
                </tr>
              </thead>
              
              <tbody>
           {{each api_result_field as value key}}
                <tr>
                  <td>{{value.name}}</td>
                  <td>{{value.type}}</td>
                  <td class="pr"><div class="text-overflow-fix w3" >{{value.desc}}</div>
                      <a data-show-intro="" class="text-overflow-fix"><span>展开</span><i class="ml5 caret caret-b-9b caret-down"></i></a></td>
                </tr>
           {{/each}}
             </tbody>
            </table>
            </div>
			
          </div>
          <div class="cls"></div>
        </div>
        {{/if}}

      {{if api_result_sample}}
		  <div class="wz none"><strong>JSON返回示例:</strong></div>
        <textarea class="nrtextarea _json_text" disabled="disabled">{{api_result_sample}}</textarea>
      </div>
      {{/if}}

      <div class="right" id="con_one_2" style="display: none">
	  
	    <!-- 错误代码 -->
        {{if api_error_codes}}
        <div class="lbk none">
          <div class="wzz">错误代码:</div>
          <div class="lb">
		  
            <div class="table-responsive">
            <table class="table table-bordered table-striped">
              <colgroup>
              <col class="col-xs-3">
              <col class="col-xs-3">
              <col class="col-xs-4">
              </colgroup>
              <thead>
                <tr>
                  <th class="text-left">错误码</th>
                  <th class="text-left">错误码返回</th>
                  <th class="text-left">说明</th>
                </tr>
              </thead>
              <tbody>
            <!-- 循环go -->
            
            {{each api_error_codes as value key}}
                <tr>
                  <td>{{value.code}}</td>
                  <td>{{value.info}}</td>
                  <td class="pr"><div class="text-overflow-fix w3" >{{value.desc}}</div>
                      <a data-show-intro="" class="text-overflow-fix"><span>展开</span><i class="ml5 caret caret-b-9b caret-down"></i></a></td>
                </tr> 
           {{/each}}
            </tbody>
          </table>
          </div>

          </div>
          <div class="cls"></div>
        </div>
        {{/if}}
		<!-- 错误代码 end -->
		
      </div>
      <div class="cls"></div>
    </div>    

    </script>

		<script type="text/javascript">
function setTab(name,cursel){
	  $('#con_one_1').hide();
    $('#con_one_2').hide();
    
    $('#parent_con_one_1').removeClass("hr");
    $('#parent_con_one_2').removeClass("hr");
    
    $("#"+name).show();
    $("#parent_"+name).addClass("hr");
}
</script>
	</div>
</div>
<div class="cls"></div>
<script language="javascript" type="text/javascript" src="__PUBLIC__/js/static.js"></script>
<script language="javascript" type="text/javascript" src="__PUBLIC__/js/api.js"></script>
<script type="text/javascript">
	 
	$(function ($) {
    getServiceAPi({$data[0].service_id},{$data[0].api_id});
	});
	</script>

</body>
</html>
